package bc.swim2.ejb.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

@NamedQueries({
		@NamedQuery(name = "Admin.getAdminByUsername", query = "SELECT a FROM Admin a WHERE a.username = :username"),
		@NamedQuery(name = "Admin.getAdminByUsernamePassword", query = "SELECT a FROM Admin a WHERE a.username = :username AND a.password = :password") })
@Entity
@Table(name = "admin")
public class Admin implements Serializable {

	/**
	 * Default constructor
	 */
	public Admin() {

	}

	/**
	 * constructor with all the parameters
	 * 
	 * @param id
	 * @param username
	 * @param password
	 */
	public Admin(int id, String username, String password) {
		this.id = id;
		this.username = username;
		this.password = password;
	}

	private static final long serialVersionUID = 4509950048616893167L;

	@Id
	@GeneratedValue
	@Column(name = "Id", nullable = false)
	private int id;

	@Column(name = "Username", nullable = false)
	private String username;

	@Column(name = "Password", nullable = false)
	private String password;

	/*
	 * @Enumerated(EnumType.ORDINAL)
	 * 
	 * @Column(name="position",nullable=false) private String position;
	 * 
	 * @Column(name="email",nullable=false) private String email;
	 * 
	 * @Column(name="name",nullable=false) private String name;
	 * 
	 * @Column(name="surname",nullable=false) private String surname;
	 * 
	 * @Column(name="date of birth",nullable=false) private Date dateOfBirth;
	 * 
	 * @ManyToMany(mappedBy="ownedBy") private List<Ability> ownAbility;
	 */
	/**
	 * User type can be only USER or ADMIN
	 * 
	 * @author Caputo - Brambilla - Caputo
	 */
	/*
	 * public static enum Type { USER, ADMIN }
	 */
	/**
	 * Override of hashCode and equals functions
	 * 
	 * @author Caputo - Brambilla - Caputo
	 */
	/*
	 * @Override public int hashCode() { final int prime = 31; int result = 1;
	 * result = prime * result + ((surname == null) ? 0 : surname.hashCode());
	 * result = prime * result + ((email == null) ? 0 : email.hashCode());
	 * result = prime * result + ((username == null) ? 0 : username.hashCode());
	 * result = prime * result + ((password == null) ? 0 : password.hashCode());
	 * result = prime * result + ((name == null) ? 0 : name.hashCode()); result
	 * = prime * result + ((dateOfBirth == null) ? 0 : dateOfBirth.hashCode());
	 * return result; }
	 * 
	 * @Override public boolean equals(Object obj) { if (this == obj) return
	 * true; if (obj == null) return false; if (getClass() != obj.getClass())
	 * return false; User other = (User) obj; if (surname == null) { if
	 * (other.surname != null) return false; } else if
	 * (!surname.equals(other.surname)) return false; if (email == null) { if
	 * (other.email != null) return false; } else if
	 * (!email.equals(other.email)) return false; if (username == null) { if
	 * (other.username != null) return false; } else if
	 * (!username.equals(other.username)) return false; if (name == null) { if
	 * (other.name != null) return false; } else if (!name.equals(other.name))
	 * return false; if (password == null) { if (other.password != null) return
	 * false; } else if (!password.equals(other.password)) return false; if
	 * (dateOfBirth == null) { if (other.dateOfBirth != null) return false; }
	 * else if (!dateOfBirth.equals(other.dateOfBirth)) return false; return
	 * true; }
	 */

	/**
	 * Getter method for username attribute
	 * 
	 * @return username
	 */
	public String getUsername() {
		return username;
	}

	/**
	 * Setter method for username attribute
	 * 
	 * @param username
	 */
	public void setUsername(String username) {
		this.username = username;
	}

	/**
	 * Getter method for password attribute
	 * 
	 * @return password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * Setter method for password attribute
	 * 
	 * @param password
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}
}
